package com.moonfish.base.repository;

import com.moonfish.base.model.menu.Menu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by mayu on 2017/7/10.
 * email:showmara@qq.com
 */
public interface MenuRepository extends JpaRepository<Menu, String> {
    Menu findById(String id);

    @Query("SELECT m from Menu m, Role r where r.name=?1 order by m.level")
    List<Menu> getMenuTree(String roleId);
}
